bitkeeper revision 1.1159.212.52 (41fa6980PfhDt-hKCfacnyHcFB7DNQ)
authorkaf24@scramble.cl.cam.ac.uk <kaf24@scramble.cl.cam.ac.uk>
Fri, 28 Jan 2005 16:34:08 +0000 (16:34 +0000)
committerkaf24@scramble.cl.cam.ac.uk <kaf24@scramble.cl.cam.ac.uk>
Fri, 28 Jan 2005 16:34:08 +0000 (16:34 +0000)
Make page allocator 64-bit safe.
Signed-off-by: keir.fraser@cl.cam.ac.uk
xen/arch/x86/memory.c
xen/common/page_alloc.c

index 69bca437d95c290733ef8fbd68c318bf94c7ff32..cfc37e84aa5cabeed214896ddb0041a376229172 100644 (file)
@@ -148,13 +148,18 @@ unsigned long max_page;
 
 void __init init_frametable(void)
 {
-#ifdef __i386__
+#if defined(__i386__)
     unsigned long i, p;
+#endif
 
-    frame_table      = (struct pfn_info *)FRAMETABLE_VIRT_START;
     frame_table_size = max_page * sizeof(struct pfn_info);
     frame_table_size = (frame_table_size + PAGE_SIZE - 1) & PAGE_MASK;
 
+#if defined(__x86_64__)
+    frame_table = __va(alloc_boot_pages(frame_table_size, 4UL << 20));
+#elif defined(__i386__)
+    frame_table = (struct pfn_info *)FRAMETABLE_VIRT_START;
+
     for ( i = 0; i < frame_table_size; i += (4UL << 20) )
     {
         p = alloc_boot_pages(min(frame_table_size - i, 4UL << 20), 4UL << 20);
@@ -163,9 +168,9 @@ void __init init_frametable(void)
         idle_pg_table[(FRAMETABLE_VIRT_START + i) >> L2_PAGETABLE_SHIFT] =
             mk_l2_pgentry(p | __PAGE_HYPERVISOR | _PAGE_PSE);
     }
+#endif
 
     memset(frame_table, 0, frame_table_size);
-#endif
 }
 
 void arch_init_memory(void)
index 09674a38f1ac9c5283140c4a927018331b11bce8..eae1692eb1b37c0b927b2736a6f835198cc2ea3d 100644 (file)
@@ -49,8 +49,9 @@ static unsigned long  bitmap_size; /* in bytes */
 static unsigned long *alloc_bitmap;
 #define PAGES_PER_MAPWORD (sizeof(unsigned long) * 8)
 
-#define allocated_in_map(_pn) \
-(alloc_bitmap[(_pn)/PAGES_PER_MAPWORD] & (1<<((_pn)&(PAGES_PER_MAPWORD-1))))
+#define allocated_in_map(_pn)                 \
+( !! (alloc_bitmap[(_pn)/PAGES_PER_MAPWORD] & \
+     (1UL<<((_pn)&(PAGES_PER_MAPWORD-1)))) )
 
 /*
  * Hint regarding bitwise arithmetic in map_{alloc,free}:
@@ -79,13 +80,13 @@ static void map_alloc(unsigned long first_page, unsigned long nr_pages)
 
     if ( curr_idx == end_idx )
     {
-        alloc_bitmap[curr_idx] |= ((1<<end_off)-1) & -(1<<start_off);
+        alloc_bitmap[curr_idx] |= ((1UL<<end_off)-1) & -(1UL<<start_off);
     }
     else 
     {
-        alloc_bitmap[curr_idx] |= -(1<<start_off);
-        while ( ++curr_idx < end_idx ) alloc_bitmap[curr_idx] = ~0L;
-        alloc_bitmap[curr_idx] |= (1<<end_off)-1;
+        alloc_bitmap[curr_idx] |= -(1UL<<start_off);
+        while ( ++curr_idx < end_idx ) alloc_bitmap[curr_idx] = ~0UL;
+        alloc_bitmap[curr_idx] |= (1UL<<end_off)-1;
     }
 }
 
@@ -108,13 +109,13 @@ static void map_free(unsigned long first_page, unsigned long nr_pages)
 
     if ( curr_idx == end_idx )
     {
-        alloc_bitmap[curr_idx] &= -(1<<end_off) | ((1<<start_off)-1);
+        alloc_bitmap[curr_idx] &= -(1UL<<end_off) | ((1UL<<start_off)-1);
     }
     else 
     {
-        alloc_bitmap[curr_idx] &= (1<<start_off)-1;
+        alloc_bitmap[curr_idx] &= (1UL<<start_off)-1;
         while ( ++curr_idx != end_idx ) alloc_bitmap[curr_idx] = 0;
-        alloc_bitmap[curr_idx] &= -(1<<end_off);
+        alloc_bitmap[curr_idx] &= -(1UL<<end_off);
     }
 }
 
@@ -483,11 +484,11 @@ struct pfn_info *alloc_domheap_pages(struct domain *d, unsigned int order)
             pfn_stamp = pg[i].tlbflush_timestamp;
             for ( j = 0; (mask != 0) && (j < smp_num_cpus); j++ )
             {
-                if ( mask & (1<<j) )
+                if ( mask & (1UL<<j) )
                 {
                     cpu_stamp = tlbflush_time[j];
                     if ( !NEED_FLUSH(cpu_stamp, pfn_stamp) )
-                        mask &= ~(1<<j);
+                        mask &= ~(1UL<<j);
                 }
             }